﻿using System;
using PetaPoco;

namespace doufu.Service
{
    public class CommonDac
    {
        private const string ConnName = "StoryDb";

        public static TReturn Query<TReturn>(Func<Database, TReturn> func)
        {
            using (var db = new Database(ConnName))
            {
                return func(db);
            }
        }

        public static void Query(Action<Database> func)
        {
            using (var db = new Database(ConnName))
            {
                func(db);
            }
        }
    }
}